/* Class62_Sub1_Sub1 - Decompiled by JODE
 * Visit http://jode.sourceforge.net/
 */
import java.io.ByteArrayInputStream;

import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.Receiver;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;
import javax.sound.midi.ShortMessage;

public class Class62_Sub1_Sub1 extends Class62_Sub1 implements Receiver
{
    public static Sequencer aSequencer2160;
    public static volatile boolean aBoolean2161;
    public static Receiver aReceiver2162 = null;
    
    public synchronized void method1055(int i, int i_0_, int i_1_) {
	if (aSequencer2160 != null) {
	    if (i_1_ != 0)
		method1047(58);
	    method1068((byte) -9, i, -1L, i_0_);
	}
    }
    
    public void method1051(int i, byte[] is, byte i_2_, boolean bool) {
	if (aSequencer2160 != null) {
	    try {
		Sequence sequence
		    = MidiSystem.getSequence(new ByteArrayInputStream(is));
		aSequencer2160.setSequence(sequence);
		if (i_2_ <= 73)
		    method1054(-47);
		aSequencer2160.setLoopCount(bool ? -1 : 0);
		method1068((byte) -9, 0, -1L, i);
		aBoolean2161 = true;
		aSequencer2160.start();
	    } catch (Exception exception) {
		/* empty */
	    }
	}
    }
    
    public void method1047(int i) {
	if (aSequencer2160 != null) {
	    aSequencer2160.close();
	    aSequencer2160 = null;
	}
	if (aReceiver2162 != null) {
	    aReceiver2162.close();
	    aReceiver2162 = null;
	}
	if (i <= 100)
	    aReceiver2162 = null;
    }
    
    public synchronized void send(MidiMessage midimessage, long l) {
	if (aBoolean2161) {
	    byte[] is = midimessage.getMessage();
	    if (!method1060(is[0] & 0xff, is[1], is.length >= 3 ? is[2] : 0,
			    l))
		aReceiver2162.send(midimessage, l);
	}
    }
    
    public void method1053(int i, byte i_3_) {
	if (aSequencer2160 != null) {
	    method1061(-1L, true, i);
	    if (i_3_ <= 44)
		method1047(69);
	}
    }
    
    public void method1054(int i) {
	if (i != 0)
	    close();
    }
    
    public void method1065(int i, int i_4_, int i_5_, long l) {
	try {
	    ShortMessage shortmessage = new ShortMessage();
	    shortmessage.setMessage(i, i_4_, i_5_);
	    aReceiver2162.send(shortmessage, l);
	} catch (InvalidMidiDataException invalidmididataexception) {
	    /* empty */
	}
    }
    
    public Class62_Sub1_Sub1() {
	try {
	    aReceiver2162 = MidiSystem.getReceiver();
	    aSequencer2160 = MidiSystem.getSequencer(false);
	    aSequencer2160.getTransmitter().setReceiver(this);
	    aSequencer2160.open();
	    method1062(-1L, 0);
	} catch (Exception exception) {
	    Queue.method987(-30574);
	}
    }
    
    public void close() {
	/* empty */
    }
    
    public void method1048(boolean bool) {
	if (aSequencer2160 != null) {
	    aBoolean2161 = bool;
	    aSequencer2160.stop();
	    method1062(-1L, 0);
	}
    }
    
    static {
	aSequencer2160 = null;
	aBoolean2161 = false;
    }
}
